package com.course.file.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

/**
 * @author: Durian
 * @date: 2021/5/3 17:49
 */
@Slf4j
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    @Resource
    private FileUploadConfig fileUploadConfig;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler(fileUploadConfig.getPath()).addResourceLocations("file:" + fileUploadConfig.getLocation());
        log.info("文件外部访问路径: 【{}】", fileUploadConfig.getPath());
        log.info("文件本机存储路径: 【{}】", fileUploadConfig.getLocation());
    }
}
